﻿<%@ Page Language="C#" MasterPageFile="~/WebSite/manager.Master" AutoEventWireup="true" CodeFile="m_data_testresult.aspx.cs" Inherits="WebSite_m_data_testresult" Title="无标题页" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<style type="text/css">
        .InfoStyle
        {
        	margin:25px auto;
        	width:635px;
        	overflow:visible;
       	}
       	.InfoStyle h1
       	{
       		font-size:20px;
       		background-image:url(../images/Clip.png);
       		background-repeat:no-repeat;
       		width:300px;
       		margin:-23px auto auto 180px;
       		padding-top:15px;
       		padding-left:50px;
       		height:40px;
       	}
       	.InsertBtnStyle
       	{
       		margin:5px 240px auto;
    	    width:90px;
    	    height:30px;
    	    background-color:#669DF0;
    	    font-size:16px;
    	    font-weight:bold;
    	    color:#FFFFFF;
       	}
    </style>
    <div class="InfoStyle">
        <h1>体测信息表</h1>
        <br />
        <asp:GridView ID="UserDetailGridView" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False"  DataKeyNames="UserId,TestDate"
            DataSourceID="SqlDataSource1" CellPadding="2" Font-Size="11px" 
                                        PageSize="20" BackColor="White" 
            BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px">
            <RowStyle ForeColor="#000066" />
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                <asp:BoundField DataField="UserId" HeaderText="用户ID" ControlStyle-Width="40px"
                    SortExpression="UserId" />
                <asp:BoundField DataField="TestDate" HeaderText="测试时间" ItemStyle-Width="60px" ControlStyle-Width="60px" DataFormatString ="{0:yyyy-MM-dd}"
                    SortExpression="TestDate" >
<ControlStyle Width="60px"></ControlStyle>

<ItemStyle Width="60px"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="Weight" HeaderText="体重" ItemStyle-Width="25px" ControlStyle-Width="25px" 
                    SortExpression="Weight" >
<ControlStyle Width="25px"></ControlStyle>

<ItemStyle Width="25px"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="Height" HeaderText="身高" ControlStyle-Width="30px" 
                    SortExpression="Height" >
<ControlStyle Width="30px"></ControlStyle>
                </asp:BoundField>
                <asp:BoundField DataField="VitalCapacity" HeaderText="肺活量"  
                    ItemStyle-Width="30px" ControlStyle-Width="30px"
                    SortExpression="VitalCapacity" >
<ControlStyle Width="80px"></ControlStyle>

<ItemStyle Width="30px"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="StaminaName" HeaderText="耐力项目名称"  ControlStyle-Width="50px"
                    SortExpression="StaminaName" >
<ControlStyle Width="50px"></ControlStyle>
                </asp:BoundField>
                <asp:BoundField DataField="Stamina" HeaderText="耐力项目成绩" ItemStyle-Width="30px"  ControlStyle-Width="30px"
                    SortExpression="Stamina" >
<ControlStyle Width="30px"></ControlStyle>

<ItemStyle Width="30px"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="StrengthName" HeaderText="柔韧力量项目名称" ItemStyle-Width="45px" ControlStyle-Width="45px" 
                    SortExpression="StrengthName" >
<ControlStyle Width="40px"></ControlStyle>

<ItemStyle Width="45px"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="Strength" HeaderText="柔韧力量力量项目成绩"  ItemStyle-Width="30px" ControlStyle-Width="30px"
                    SortExpression="Strength" >
<ControlStyle Width="30px"></ControlStyle>

<ItemStyle Width="30px"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="SpeedName" HeaderText="速度灵巧性项目名称" ItemStyle-Width="40px" ControlStyle-Width="40px"
                    SortExpression="SpeedName" >
<ControlStyle Width="40px"></ControlStyle>

<ItemStyle Width="40px"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="Speed" HeaderText="速度灵巧性项目成绩"  
                    ItemStyle-Width="30px" ControlStyle-Width="30px"
                    SortExpression="Speed" >
<ControlStyle Width="30px"></ControlStyle>

<ItemStyle Width="30px"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="Other" HeaderText="奖惩信息"  ItemStyle-Width="50px" 
                    ControlStyle-Width="50px" SortExpression="Other" >
<ControlStyle Width="50px"></ControlStyle>

<ItemStyle Width="50px"></ItemStyle>
                </asp:BoundField>
            </Columns>
            <FooterStyle BackColor="White" ForeColor="#000066" />
            <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
            <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
        </asp:GridView>
        <br />
        <table style="font-size:12px;">
            <tr>
                <td>用户ID</td>
                <td>体重(kg)</td>
                <td>身高(cm)</td>
                <td>肺活量(ml)</td>
                <td>耐力项目名称</td>
                <td>耐力项目成绩</td>
                <td>柔韧力量项目</td>
                <td>柔韧力量项目成绩</td>
                <td>速度灵巧性项目名称</td>
                <td>速度灵巧性项目成绩</td>
                <td>奖惩性信息</td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="UserIdTextBox" runat="server" style="width:40px;" 
                        MaxLength="20" EnableViewState="False" Wrap="False"/>
                </td>
                <td>
                    <asp:TextBox ID="WeightTextBox" runat="server" style="width:30px;" 
                        MaxLength="20" EnableViewState="False" Wrap="False"/>
                </td>
                <td>
                    <asp:TextBox ID="HeightTextBox" runat="server" style="width:40px;" 
                        MaxLength="10" EnableViewState="False" Wrap="False"/>
                </td>
                <td>
                    <asp:TextBox ID="VitalCapacityTextBox" runat="server" style="width:40px" />
                </td>
                <td>
                    <asp:DropDownList ID="StaminaDropDownList" runat="server" Width="65px" 
                        DataSourceID="SqlDataSource2" DataTextField="TestName" 
                        DataValueField="TestName" />
                </td>
                <td>
                    <asp:TextBox ID="StaminaTextBox" runat="server" style="width:50px;" 
                        EnableViewState="False" Wrap="False" />
                </td>
                <td>
                    <asp:DropDownList ID="StrengthDownList" runat="server" 
                        DataSourceID="SqlDataSource3"  DataTextField="TestName" 
                        DataValueField="TestName" Width="70px"/>
                </td>
                <td>
                    <asp:TextBox ID="StrengthTextBox" runat="server"  Width="50px"/>
                </td>
                <td>
                    <asp:DropDownList ID="SpeedDropDownList" runat="server" 
                        DataSourceID="SqlDataSource4" DataTextField="TestName" 
                        DataValueField="TestName" Width="70px" />
                </td>
                <td>
                    <asp:TextBox ID="SpeedTextBox" runat="server" Width="50px"/>
                </td>
                <td>
                    <asp:DropDownList ID="OtherDropDownList" runat="server" runat="server" 
                        DataSourceID="SqlDataSource5" DataTextField="TestName" 
                        DataValueField="TestName" Width="70px" />
                </td>
           </tr>
        </table>
        <asp:Button ID="InsertBtn" runat="server" Text="插入数据" OnClick="InsertBtn_Click" CssClass="InsertBtnStyle"/>
    </div>
  <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:CSHDBConnectionString %>" 
            
        SelectCommand="SELECT UserId, TestDate, Weight, Height, VitalCapacity, StaminaName, Stamina, StrengthName, Strength, SpeedName, Speed, Other FROM PhysiqueTestResultView" 
        DeleteCommand="DELETE FROM PhysiqueTest WHERE (UserId = @UserID) AND (TestDate = @TestDate);"  
        UpdateCommand="update PhysiqueTest
set Result=@Height
where UserId=@UserId and TestDate=@TestDate and TestName='身高' ;
update PhysiqueTest
set Result=@Weight
where UserId=@UserId and TestDate=@TestDate and TestName='体重' ;
update PhysiqueTest
set Result=@VitalCapacity
where UserId=@UserId and TestDate=@TestDate and TestName='肺活量' ;
update StaminaView
set TestName=@StaminaName,Result=@Stamina
where UserId=@UserId and TestDate=@TestDate ;
update StrengthView
set TestName=@StrengthName,Result=@Strength
where UserId=@UserId and TestDate=@TestDate ;
update SpeedView
set TestName=@SpeedName,Result=@Speed
where UserId=@UserId and TestDate=@TestDate ;" >
            <DeleteParameters>
                <asp:Parameter Name="UserID" />
                <asp:Parameter Name="TestDate" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Height" />
                <asp:Parameter Name="UserId" />
                <asp:Parameter Name="TestDate" />
                <asp:Parameter Name="Weight" />
                <asp:Parameter Name="VitalCapacity" />
                <asp:Parameter Name="StaminaName" />
                <asp:Parameter Name="Stamina" />
                <asp:Parameter Name="StrengthName" />
                <asp:Parameter Name="Strength" />
                <asp:Parameter Name="SpeedName" />
                <asp:Parameter Name="Speed" />
            </UpdateParameters>
        </asp:SqlDataSource>


    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:CSHDBConnectionString %>" 
        SelectCommand="SELECT [TestName] FROM [TargetCatagory] WHERE ([ItemCatagory] = @ItemCatagory)">
        <SelectParameters>
            <asp:Parameter DefaultValue="耐力项目" Name="ItemCatagory" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:CSHDBConnectionString %>" 
        SelectCommand="SELECT [TestName] FROM [TargetCatagory] WHERE ([ItemCatagory] = @ItemCatagory)">
        <SelectParameters>
            <asp:Parameter DefaultValue="柔韧、力量项目" Name="ItemCatagory" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>


    <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
        ConnectionString="<%$ ConnectionStrings:CSHDBConnectionString %>" 
        SelectCommand="SELECT [TestName] FROM [TargetCatagory] WHERE ([ItemCatagory] = @ItemCatagory)">
        <SelectParameters>
            <asp:Parameter DefaultValue="速度、灵巧项目" Name="ItemCatagory" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    
    <asp:SqlDataSource ID="SqlDataSource5" runat="server" 
        ConnectionString="<%$ ConnectionStrings:CSHDBConnectionString %>" 
        SelectCommand="SELECT [TestName] FROM [TargetCatagory] WHERE ([ItemCatagory] = @ItemCatagory)">
        <SelectParameters>
            <asp:Parameter DefaultValue="奖惩项目" Name="ItemCatagory" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>


    <asp:Label ID="WarnLabel" runat="server" ForeColor="Red" Visible="false" />    
</asp:Content>

